<template>
  <el-table
    ref="table" class="table-equip" :data="equipState"
    :header-cell-style="{'text-align':'center', 'font-weight':'700', 'font-size':'medium'}"
    :cell-style="{'text-align':'center', 'font-size':'medium'}">
    <el-table-column prop="shebei" label="设备"></el-table-column>
    <el-table-column prop="state_1" label="状态1"></el-table-column>
    <el-table-column prop="state_2" label="状态2"></el-table-column>
    <el-table-column prop="state_3" label="状态3"></el-table-column>
    <el-table-column prop="state_4" label="状态4"></el-table-column>
    <el-table-column prop="state_5" label="状态5"></el-table-column>
    <el-table-column prop="state_6" label="状态6"></el-table-column>
    <el-table-column prop="state_real" label="预测状态"></el-table-column>
  </el-table>
</template>

<script>
export default {
  name: 'DiagnosisTable',
  data () {
    return {
      parameter: [],
      max_p: '',
      max_i: '',
      signal1: 0,
      equipState: [{
        shebei: '焊机1',
        state_1: '',
        state_2: '',
        state_3: '',
        state_4: '',
        state_5: '',
        state_6: '',
        state_real: ''
      },
      {
        shebei: '焊机2',
        state_1: '',
        state_2: '',
        state_3: '',
        state_4: '',
        state_5: '',
        state_6: '',
        state_real: ''
      },
      {
        shebei: '焊机3',
        state_1: '',
        state_2: '',
        state_3: '',
        state_4: '',
        state_5: '',
        state_6: '',
        state_real: ''
      },
      {
        shebei: '焊机4',
        state_1: '',
        state_2: '',
        state_3: '',
        state_4: '',
        state_5: '',
        state_6: '',
        state_real: ''
      },
      {
        shebei: '焊机5',
        state_1: '',
        state_2: '',
        state_3: '',
        state_4: '',
        state_5: '',
        state_6: '',
        state_real: ''
      }]
    }
  },
  methods: {
    RefreshState () {
      this.$http({
        url: this.$http.adornUrl('/P2/fault'),
        method: 'get',
      }).then(response => {
        this.parameter = response.data
      })
      this.hanji_1(this.parameter)
      this.hanji_2(this.parameter)
      this.hanji_3(this.parameter)
      this.hanji_4(this.parameter)
      this.hanji_5(this.parameter)
    },
    hanji_1 (param) {
      this.equipState[0].state_1 = param[0][0]
      this.equipState[0].state_2 = param[0][1]
      this.equipState[0].state_3 = param[0][2]
      this.equipState[0].state_4 = param[0][3]
      this.equipState[0].state_5 = param[0][4]
      this.equipState[0].state_6 = param[0][5]
      this.max_p = param[0][0]
      this.max_i = 1
      for (var i = 0; i < 6; i++) {
        if (param[0][i] > this.max_p) {
          this.max_p = param[0][i]
          this.max_i = i + 1
        }
      }
      this.equipState[0].state_real = '状态' + this.max_i
    },
    hanji_2 (param) {
      this.equipState[1].state_1 = param[1][0]
      this.equipState[1].state_2 = param[1][1]
      this.equipState[1].state_3 = param[1][2]
      this.equipState[1].state_4 = param[1][3]
      this.equipState[1].state_5 = param[1][4]
      this.equipState[1].state_6 = param[1][5]
      this.max_p = param[1][0]
      this.max_i = 1
      for (var i = 0; i < 6; i++) {
        if (param[1][i] > this.max_p) {
          this.max_p = param[1][i]
          this.max_i = i + 1
        }
      }
      this.equipState[1].state_real = '状态' + this.max_i
    },
    hanji_3 (param) {
      this.equipState[2].state_1 = param[2][0]
      this.equipState[2].state_2 = param[2][1]
      this.equipState[2].state_3 = param[2][2]
      this.equipState[2].state_4 = param[2][3]
      this.equipState[2].state_5 = param[2][4]
      this.equipState[2].state_6 = param[2][5]
      this.max_p = param[2][0]
      this.max_i = 1
      for (var i = 0; i < 6; i++) {
        if (param[2][i] > this.max_p) {
          this.max_p = param[2][i]
          this.max_i = i + 1
        }
      }
      this.equipState[2].state_real = '状态' + this.max_i
    },
    hanji_4 (param) {
      this.equipState[3].state_1 = param[3][0]
      this.equipState[3].state_2 = param[3][1]
      this.equipState[3].state_3 = param[3][2]
      this.equipState[3].state_4 = param[3][3]
      this.equipState[3].state_5 = param[3][4]
      this.equipState[3].state_6 = param[3][5]
      this.max_p = param[3][0]
      this.max_i = 1
      for (var i = 0; i < 6; i++) {
        if (param[3][i] > this.max_p) {
          this.max_p = param[3][i]
          this.max_i = i + 1
        }
      }
      this.equipState[3].state_real = '状态' + this.max_i
    },
    hanji_5 (param) {
      this.equipState[4].state_1 = param[4][0]
      this.equipState[4].state_2 = param[4][1]
      this.equipState[4].state_3 = param[4][2]
      this.equipState[4].state_4 = param[4][3]
      this.equipState[4].state_5 = param[4][4]
      this.equipState[4].state_6 = param[4][5]
      this.max_p = param[4][0]
      this.max_i = 1
      for (var i = 0; i < 6; i++) {
        if (param[4][i] > this.max_p) {
          this.max_p = param[4][i]
          this.max_i = i + 1
        }
      }
      this.equipState[4].state_real = '状态' + this.max_i
    }
  }
}
</script>

<style scoped>

</style>
